
class List 

  def execute(source, args)
    nodes = source.children
    if args.length > 0
      items = args[0].split(/\//)
      items.each do |item|
        nodes = list_children_of_named_node(nodes, source, item)
      end
    end
    return if !nodes
    nodes.each {|node| puts node.name} 
  end 

  private 
  def list_children_of_named_node(nodes, source, name)
    node = nodes.find {|n| n.name == name} if nodes
    if node
      source.get_children_of(node)
    else
      puts "nothing found for '#{name}'"
      nil
    end 
  end
end